package com.viewmode1;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

public class MainViewModel extends ViewModel {
    private MutableLiveData<Integer> numberLiveData;

//    MainViewModel(){
//        numberLiveData = new MutableLiveData<>();
//        numberLiveData.setValue(0);
//    }

    public MutableLiveData<Integer> getNumberLiveData() {
        if (numberLiveData == null) {
            numberLiveData = new MutableLiveData<>();
            numberLiveData.setValue(0);
        }
        return numberLiveData;
    }


    public void add1Number() {
        numberLiveData.setValue(numberLiveData.getValue() + 1);
    }

    public void add2Number() {
        numberLiveData.setValue(numberLiveData.getValue() + 2);
    }


}
